package com.shudes.util;

import java.util.*;

public class TwoWayMap<A,B> {
	protected HashMap<A,B> aToB;
	protected HashMap<B,A> bToA;
	
	public TwoWayMap() { 
		aToB = new HashMap<A,B>(); 
		bToA = new HashMap<B,A>(); 
	}
	
	public B getA(A a) { 
		return aToB.get(a); 
	}
	
	public A getB(B b) { 
		return bToA.get(b); 
	}
	
	public Map<A,B> getAMap() { 
		return Collections.unmodifiableMap(aToB); 
	}
	
	public Map<B,A> getBMap() { 
		return Collections.unmodifiableMap(bToA); 
	}
	
	public void put(A a, B b) { 
		aToB.put(a, b); 
		bToA.put(b,a); 
	}

}
